package sr.myserver.controller;

import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sr.myserver.entity.SysUsers;
import sr.myserver.service.SysUsersService;
import sr.myserver.vo.SelectData;
import sr.myserver.vo.common.Basic;
import sr.myserver.vo.common.PageRequest;
import sr.myserver.vo.common.PageResponse;

@Slf4j
@RestController
@RequestMapping("/sysusers")
@Api(tags = "用户信息")
public class SysUsersController {

    @Autowired
    SysUsersService sysUsersService;

    @GetMapping("/{id}")
    @Operation(summary = "指定ID获取数据")
    public SysUsers get(@PathVariable("id") String id) {
        return sysUsersService.get(id);
    }

    @PostMapping
    @Operation(summary = "添加数据")
    public Basic.Response post(@RequestBody SysUsers entity) {
        return sysUsersService.add(entity);
    }

    @PutMapping("/edit")
    @Operation(summary = "指定ID修改数据")
    public Basic.Response put(@RequestBody SysUsers entity) {
        return sysUsersService.update(entity);
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "指定ID删除数据")
    public Basic.Response deleteById(@PathVariable("id") String id) {
        return sysUsersService.deleteById(id);
    }

    @PutMapping
    @Operation(summary = "分页列表数据")
    public PageResponse<SysUsers> queryTables(@RequestBody PageRequest request) {
        return sysUsersService.queryTables(request);
    }

    @PostMapping("/select")
    @Operation(summary = "分页下拉数据")
    public PageResponse<SelectData> querySelect(@RequestBody PageRequest request) {
        return sysUsersService.querySelect(request);
    }
}

